﻿using KELT.KELTObjects.ViewportObjectModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Animation;

namespace KELT.Animation.Animation2D
{


    public class MaskAnimation : IAnimation
    {
        private DoubleAnimation maskAnimation1;
        private DoubleAnimation maskAnimation2;


        public MaskAnimation()
        {

            maskAnimation1 = new DoubleAnimation();
            maskAnimation2 = new DoubleAnimation();

        }
        public override void SetAnimation(Storyboard myStoryboard, ViewportObj obj)
        {
            animationName = "마스크";

            maskAnimation1.Duration = TimeSpan.FromSeconds(endTime - startTime);
            maskAnimation1.BeginTime = TimeSpan.FromSeconds(startTime);
            maskAnimation1.From = 0;
            maskAnimation1.To = 1;


            Storyboard.SetTargetName(maskAnimation1, "TransparentStop" + obj.getIndexNumber());
            Storyboard.SetTargetProperty(maskAnimation1, new PropertyPath("Offset"));

            myStoryboard.Children.Add(maskAnimation1);


            maskAnimation2.Duration = TimeSpan.FromSeconds(endTime - startTime);
            maskAnimation2.BeginTime = TimeSpan.FromSeconds(startTime);
            maskAnimation2.From = 0;
            maskAnimation2.To = 1;


            Storyboard.SetTargetName(maskAnimation2, "BlackStop" + obj.getIndexNumber());
            Storyboard.SetTargetProperty(maskAnimation2, new PropertyPath("Offset"));

            myStoryboard.Children.Add(maskAnimation2);

        }

        public override void changeAnimation(Storyboard myStoryboard)
        {
            myStoryboard.Children.Remove(maskAnimation1);
            myStoryboard.Children.Remove(maskAnimation2);

            maskAnimation1.Duration = TimeSpan.FromSeconds(endTime - startTime);
            maskAnimation1.BeginTime = TimeSpan.FromSeconds(startTime);

            maskAnimation2.Duration = TimeSpan.FromSeconds(endTime - startTime);
            maskAnimation2.BeginTime = TimeSpan.FromSeconds(startTime);

            myStoryboard.Children.Add(maskAnimation1);
            myStoryboard.Children.Add(maskAnimation2);
        }


        public override void deleteAnimation(Storyboard myStoryboard)
        {
            myStoryboard.Children.Remove(maskAnimation1);
            myStoryboard.Children.Remove(maskAnimation2);
        }

    }
}
